//
//  CellForVCForActivityCell.m
//  echo
//
//  Created by dllo on 16/3/8.
//  Copyright © 2016年 Danny. All rights reserved.
//

#define WIDTH [UIScreen mainScreen].bounds.size.width / 414
#define HEIGHT [UIScreen mainScreen].bounds.size.height / 736

#import "CellForVCForActivityCell.h"
#import "ModelForActivityCellVCSectionPrize.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import <DKNightVersion.h>

@interface CellForVCForActivityCell ()
@property (nonatomic, retain)UIView *viewOfBack;
@property (nonatomic, retain)UIImageView *image;
@property (nonatomic, retain)UILabel *labelForTop;
@property (nonatomic, retain)UILabel *labelForMid;
@property (nonatomic, retain)UILabel *labelForBottom;
@end

@implementation CellForVCForActivityCell

- (void)dealloc{
    [_viewOfBack release];
    [_image release];
    [_labelForTop release];
    [_labelForMid release];
    [_labelForBottom release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.viewOfBack = [[UIView alloc]init];
        [self.contentView addSubview:self.viewOfBack];
        [self.viewOfBack release];
        
        self.image = [[UIImageView alloc]init];
        [self.viewOfBack addSubview:self.image];
        [self.image release];
        
        self.labelForTop = [[UILabel alloc]init];
        [self.viewOfBack addSubview:self.labelForTop];
        [self.labelForTop release];
        
        self.labelForMid = [[UILabel alloc]init];
        [self.viewOfBack addSubview:self.labelForMid];
        [self.labelForMid release];
        
        self.labelForBottom = [[UILabel alloc]init];
        [self.viewOfBack addSubview:self.labelForBottom];
        [self.labelForBottom release];
        
    }
    return self;
}

- (void)layoutSubviews{
    self.viewOfBack.frame = self.contentView.frame;
    self.viewOfBack.dk_backgroundColorPicker = DKColorWithColors([UIColor whiteColor], [UIColor colorWithRed:17 / 256.f green:27 / 256.f blue:47 / 256.f alpha:1]);
    self.image.frame = CGRectMake(10 * WIDTH, 10 * HEIGHT, 100 * WIDTH, 70 * HEIGHT);
    self.labelForTop.frame = CGRectMake(116 * WIDTH, 10 * HEIGHT, self.contentView.frame.size.width - 126 * WIDTH, 25 * HEIGHT);
    self.labelForMid.frame = CGRectMake(116 * WIDTH, 37.5 * HEIGHT, self.contentView.frame.size.width - 126 * WIDTH, 20 * HEIGHT);
    self.labelForBottom.frame = CGRectMake(116 * WIDTH, 60 * HEIGHT, self.contentView.frame.size.width - 126 * WIDTH, 20 * HEIGHT);
}

- (void)passModel:(ModelForActivityCellVCSectionPrize *)model{
    [self.image sd_setImageWithURL:[NSURL URLWithString:model.pic]];
    self.labelForTop.text = model.title;
    self.labelForTop.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    self.labelForTop.font = [UIFont fontWithName:@"ArialUnicodeMS" size:17.0];

    self.labelForMid.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    NSString *str = @"由";
    NSString *strForMid = [str stringByAppendingFormat:@" %@ 官方提供", model.provider];
    NSRange range1 = [strForMid rangeOfString:model.provider];
    NSMutableAttributedString *attribue1 = [[NSMutableAttributedString alloc]initWithString:strForMid];
    [attribue1 addAttributes:@{NSForegroundColorAttributeName: [UIColor greenColor]} range:range1];
    [self.labelForMid setText:strForMid];
    [self.labelForMid setAttributedText:attribue1];
    self.labelForMid.font = [UIFont fontWithName:@"Arial" size:15];
    [attribue1 release];
    
    self.labelForBottom.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    NSString *str2 = [model.total stringValue];
    NSString *str3 = @"共";
    NSString *str4 = [str2 stringByAppendingString:@"份"];
    NSString *strForBottom = [str3 stringByAppendingFormat:@"%@奖品 已全部被抽中", str4];
    NSRange range2 = [strForBottom rangeOfString:str4];
    NSMutableAttributedString *attribue2 = [[NSMutableAttributedString alloc]initWithString:strForBottom];
    [attribue2 addAttributes:@{NSForegroundColorAttributeName: [UIColor greenColor]} range:range2];
    [self.labelForBottom setText:strForBottom];
    [self.labelForBottom setAttributedText:attribue2];
    self.labelForBottom.font = [UIFont fontWithName:@"Arial" size:15];
    [attribue2 release];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
